package IC.SymbolTables.Types;

import IC.SymbolTables.SymbolTable;

public class ClassType extends InstanceType
{
	private SymbolTable _symbolTable;
	private String _classID;
	
	public ClassType(String classID, SymbolTable symbolTable)
	{
		_symbolTable = symbolTable;
		_classID = classID;
	}
	
	public String GetClassID() { return _classID; }
	public SymbolTable GetSymbolTable() { return _symbolTable; }
	public String toString() { return _classID; }
	
	public boolean IsInstanceOf(Type type)
	{
		if (!(type instanceof ClassType))
			return false;
		
		for (SymbolTable activeSymbolTable = _symbolTable; activeSymbolTable != null; activeSymbolTable = activeSymbolTable.GetFather())
			if (activeSymbolTable == ((ClassType)type)._symbolTable)
				return true;
		
		return false;
	}
}
